This is an online tutorial for the plot_map function in collEcol package by Dan Sankey
If you are interested in making a googlemap style plot or video of your solo or group GPS data, but aren’t that familiar with the documentation/help files for the collEcol package, then this tutorial should be for you. Hopefully this tutorial will help solve all your problems, but if not, or you would like me to edit the functions to perform something differently, then don’t hesitate to contact me on dwsankey@gmail.com with any questions or suggestions.
if(!require(pacman))
install.packages("pacman") # Functions for loading required libraries
## Loading required package: pacman
library(pacman)
p_load(ggmap, ggplot2 , plyr , collEcol)
Using the example data (from a pigeon homing flight)
data("solo")
plot_map(data = data , type = "solo" , image.or.vid = "image", zoom = 13)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.43538,-0.578528&zoom=13&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
Plot of a pigeon’s flight over Surrey, England
If you are happy with the parameters you would like for your video then skip straight to section 4. This section is just an example using my (very short) dataset.
It is however, really important to practice with file.to.folder = F . Firstly, to save yourself time in case you get something wrong, but also because google will only let you take a fixed number of images from their website per day. I believe this maximum is 1000 images.
# load in the data
data("group") # these data are called data2
suppressWarnings(plot_map (data = data2 , type = "group" , image.or.vid = "video", tail.size = 20, frame.size = 5, file.to.folder = F, zoom = 19)) # Warnings are supressed because there are quite a few of them. Not important if the figures look right to you and I
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449642,-0.58928&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "20 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449632,-0.589519&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "25 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449585,-0.58976&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "30 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449522,-0.589979&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "35 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449433,-0.590171&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "40 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449312,-0.590301&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "45 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449151,-0.590348&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "50 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.448967,-0.590288&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "55 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.448789,-0.590107&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "60 / 60"
Before you this next chunk it is good to set your working directory to the one to which you would like the images to store.
suppressWarnings(plot_map(data = data2, wd = getwd(), plot_name = "my_video" , file.to.folder = T, type = "group" , image.or.vid = "video", tail.size = 20, frame.size = 5, zoom = 19))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449642,-0.58928&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "20 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449632,-0.589519&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "25 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449585,-0.58976&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "30 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449522,-0.589979&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "35 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449433,-0.590171&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "40 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449312,-0.590301&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "45 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.449151,-0.590348&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "50 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.448967,-0.590288&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "55 / 60"
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.448789,-0.590107&zoom=19&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## [1] "60 / 60"
Go to your working directory and export the .png files into a movie maker software.
I highly reccommend imagej as it is efficient, free and doesn’t take up a lot of memory.
Happy coding!
:)